#include <bits/stdc++.h>
using namespace std;
int t, n, m, l, v, cnt;
double x;
struct car
{
    int dd, vv, aa;
    //juli  chusudu  jiasudu
} b[100006];
int p[100006];
bool vis[100006];
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> t;
    while (t--)
    {
        memset(vis, 0, sizeof(vis));
        cin >> n >> m >> l >> v;
        //cheshu cesuyishu changdu xiansu
        for (int i = 1; i <= n; i++)
            cin >> b[i].dd >> b[i].vv >> b[i].aa;
            //juli  chusudu  jiasudu
        for (int i = 1; i <= m; i++)
            cin >> p[i];
        for (int i = 1; i <= n; i++)
        {
            if (b[i].aa != 0)
                x = 1.0 * (v * v - b[i].vv*b[i].vv) / (2 * b[i].aa);
            for (int j = 1; j <= m; j++)
                if (b[i].aa < 0 && p[j] >= b[i].dd && p[j] < x + b[i].dd ||
                    b[i].aa > 0 && p[j] > x + b[i].dd ||
                    b[i].aa == 0 && b[i].vv > v && p[j] >= b[i].dd)
            {
                cnt++;
                vis[j] = 1;
                break;
            }
        }
        cout << cnt <<' ';
        cnt = 0;
        for (int i = 1; i <= m; i++)
            if (vis[i] == 0)
                cnt++;
        cout << cnt << '\n';
    }
    return 0;
}
